import org.cicd.devops.*
import org.cicd.enums.PipelineType
import org.cicd.utils.utils
import org.cicd.utils.log

/**
 * 构建代码上传私服
 * <p>
 *   适用场景，构建公共包
 * </p>
 * @param paramMap
 * @return
 */
def call(paramMap) {

    def pomDir = paramMap.pomDir
    def mvnCommand = paramMap.mvnCommand
    def projectType = paramMap.projectType
    def branchName = "${env.BRANCH_NAME}"
    env.branchName = branchName
    //如果不传入mvnCommand，则执行默认mvn命令
    def executeMvnCommand = ""

    executeMvnCommand=(mvnCommand==null?'mvn -U -Dmaven.test.failure.ignore=true -Dmaven.test.skip=true clean javadoc:jar deploy':mvnCommand)

    if(branchName.startsWith("master")){
        echo "master分支默认启用-Prelease"
        executeMvnCommand=executeMvnCommand+" -Prelease"
    }

    dir(pomDir) {
        def utils = new utils();
        if (utils.isWindows()) {
            bat executeMvnCommand
        }
        else {
            sh executeMvnCommand
        }

    }

}

return this